package com.zs.java.blockingqueue;

import java.util.Comparator;
import java.util.concurrent.PriorityBlockingQueue;

/**
 * 支持优先级排序的无界阻塞队列
 *
 * @author madison
 * @description
 * @date 2021/6/1 22:43
 */
public class PriorityBlockingQueueTest {
    public static void main(String[] args) throws InterruptedException {
        PriorityBlockingQueue<Integer> queue = new PriorityBlockingQueue(2,Comparator.reverseOrder());
//        System.out.println(queue.take());
        queue.add(5);
        queue.offer(6);
        queue.offer(1);
        queue.add(4);
        queue.add(2);
        queue.add(9);
        queue.add(92);
        System.out.println(queue);
    }
}
